import pyqtgraph as pg
from typing import List, Tuple

class BaseChart:
    def __init__(self, plot_widget: pg.PlotWidget):
        self.plot_widget = plot_widget
    
    def set_price_range(self, min_price: float, max_price: float, padding: float = 0.1):
        """
        设置价格范围
        
        Args:
            min_price: 最低价格
            max_price: 最高价格
            padding: 边距比例
        """
        price_range = max_price - min_price
        y_min = min_price - price_range * padding
        y_max = max_price + price_range * padding
        self.plot_widget.setYRange(y_min, y_max)
    
    def set_x_range(self, x_min: float, x_max: float):
        """
        设置X轴范围
        
        Args:
            x_min: X轴最小值
            x_max: X轴最大值
        """
        self.plot_widget.setXRange(x_min, x_max)
    
    def set_date_ticks(self, date_ticks: List[Tuple[int, str]]):
        """
        设置X轴日期刻度
        
        Args:
            date_ticks: 日期刻度列表
        """
        axis = self.plot_widget.getAxis('bottom')
        axis.setTicks([date_ticks])